#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof a)
const int MAXNODE = 10000+10, SIG = 26;
const int maxn = 1000 + 10;
const int maxm = 1000 + 10;
const int maxx = 100 + 10;
const int maxy = 100 + 10;
int tr[MAXNODE][SIG], sz, f[MAXNODE], val[MAXNODE], last[MAXNODE];
char text[maxn][maxm], P[maxx][maxy];
int cnt[maxn][maxm];
int repr[maxx]; // repr[i]为模板第i行的“代表元”
int nex[maxx]; // nex[i]为模板中与第i行相等的下一个行编号
int len[maxx]; // 模板各行的长度

int id(char c){return c-'a';}

void insert(char *s, int v){
    int p = 0, L = strlen(s);
    for (int i = 0; i < L; ++i){
        int c = id(s[i]);
        int& nx = tr[p][c];
        if(!nx) clr(tr[sz]), nx = sz, val[sz++] = 0;
        p = nx;
    }
    val[p] = v;
}
void getfail(){
    queue<int> q;
    f[0] = 0;
    for (int i = 0; i < SIG; ++i) {
        int u = tr[0][i];
        if(u) q.push(u), f[u] = 0, last[u] = 0;
    }
    while (!q.empty()){
        int u = q.front(); q.pop();
        for (int c = 0; c < SIG; ++c) {
            int v = tr[u][c];
            if(!v) {tr[u][c] = tr[f[u]][c]; continue;}
            q.push(v);
            f[v] = tr[f[u]][c];
            last[v] = val[f[v]]? f[v]:last[f[v]];
        }
    }
}


int TR;
void process_match(int pos, int v) {
    int pr = repr[v - 1]; // 匹配到得模板行编号
    int c = pos - len[pr] + 1;
    while(pr >= 0) {
        if(TR >= pr) // P的行pr出现在在T的tr行，起始列编号为c
            cnt[TR - pr][c]++;
        pr = nex[pr];
    }
}
// 递归打印以结点j结尾的所有字符串
void up(int pos, int j) {
    if(j) {
        process_match(pos, val[j]);
        up(pos, last[j]);
    }
}


void find(char *t){
    int p = 0;
    int L = strlen(t);
    for (int tc = 0; tc < L; ++tc){
        int c = id(t[tc]);
        p = tr[p][c];
        if(val[p]) up(tc, p);
        else if(last[p]) up(tc, last[p]);
    }
}


void init() {
    sz = 1;
    clr(tr[0]), clr(cnt);
}

int main() {
    int T, n, m, x, y;
    scanf("%d", &T);
    while (T--){
        scanf("%d%d", &n, &m);
        for(int i = 0; i < n; i++)
            scanf("%s", text[i]);

        scanf("%d%d", &x, &y);
        init();
        for(int i = 0; i < x; i++) {
            scanf("%s", P[i]);
            len[i] = strlen(P[i]);
            repr[i] = i;
            nex[i] = -1;
            for(int j = 0; j < i; j++)
                if(strcmp(P[i], P[j]) == 0) {
                    repr[i] = j;
                    nex[i] = nex[j];
                    nex[j] = i;
                    break;
                }
            if(repr[i] == i) insert(P[i], i+1);
        }
        getfail();

        for(TR = 0; TR < n; TR++)
            find(text[TR]);

        int ans = 0;
        for(int i = 0; i < n-x+1; i++)
            for(int j = 0; j < m-y+1; j++)
                if(cnt[i][j] == x) ans++;
        printf("%d\n", ans);
    }
    return 0;
}